package top.soulblack.purchasesale.common;

/**
 * @Author: 廉雪峰
 * @Date: 2019/5/13 20:34
 * @Version 1.0
 */
public class CodeMsg {

    private int code;

    private String msg;

    // 通用异常
    public static CodeMsg SUCCESS = new CodeMsg(1, "success");

    // 颜色管理异常
    public static CodeMsg COLOR_LIFE = new CodeMsg(100, "颜色正在被使用，无法删除");
    public static CodeMsg SORT_ERROR = new CodeMsg(101, "排序号码错误，大于100或小于1");
    public static CodeMsg COLOR_EXIST = new CodeMsg(102, "颜色已存在");
    public static CodeMsg COLOR_DELETE = new CodeMsg(103, "颜色删除失败");
    public static CodeMsg COLOR_EDIT_ERROR = new CodeMsg(104, "颜色编辑失败");
    public static CodeMsg GROUP_EDIT_ERROR = new CodeMsg(105, "分组编辑失败");
    public static CodeMsg GROUP_DELETE_ERROR = new CodeMsg(106, "分组删除失败");

    // 尺码管理异常
    public static CodeMsg SIZE_EXIST = new CodeMsg(107, "尺码已存在");
    public static CodeMsg SIZE_DELETE = new CodeMsg(108, "尺码删除失败");
    public static CodeMsg SIZE_EDIT_ERROR = new CodeMsg(109, "尺码编辑失败");
    public static CodeMsg SIZE_LIFE= new CodeMsg(99, "尺码正在被使用，无法删除");

    // 品牌管理异常
    public static CodeMsg BRAND_EXIST = new CodeMsg(110,"品牌已经存在");
    public static CodeMsg BRAND_DELETE = new CodeMsg(111, "品牌删除失败");
    public static CodeMsg BRAND_EDIT_ERROR= new CodeMsg(112, "品牌编辑失败");

    // 材质管理异常
    public static CodeMsg MATERIAL_EXIST = new CodeMsg(113,"材质已经存在");
    public static CodeMsg MATERIAL_DELETE = new CodeMsg(114, "材质删除失败");
    public static CodeMsg MATERIAL_EDIT_ERROR= new CodeMsg(115, "材质编辑失败");
    public static CodeMsg MATERIAL_LIFE= new CodeMsg(115, "材质正在被使用，无法删除");

    // 单位管理异常
    public static CodeMsg UNIT_EXIST = new CodeMsg(116, "单位已存在");
    public static CodeMsg UNIT_DELETE = new CodeMsg(117, "单位删除失败");
    public static CodeMsg UNIT_EDIT_ERROR = new CodeMsg(118, "单位编辑失败");

    // 款式管理异常
    public static CodeMsg STYLE_EXIST = new CodeMsg(119, "款式已经存在");
    public static CodeMsg STYLE_DELETE = new CodeMsg(120, "款式删除失败");
    public static CodeMsg STYLE_EDIT_ERROR = new CodeMsg(121, "款式编辑失败");
    public static CodeMsg STYLE_LIFE= new CodeMsg(125, "款式正在被使用，无法删除");

    // 季节管理异常
    public static CodeMsg SEASON_EXIST = new CodeMsg(122,"季节已经存在");
    public static CodeMsg SEASON_DELETE = new CodeMsg(123, "季节删除失败");
    public static CodeMsg SEASON_EDIT_ERROR= new CodeMsg(124, "季节编辑失败");

    // 仓库管理异常
    public static CodeMsg STORE_DELETE = new CodeMsg(201, "仓库删除失败");
    public static CodeMsg STORE_UPDATE = new CodeMsg(202, "仓库更新失败");

    // 商品管理异常
    public static CodeMsg GOODS_DELETE = new CodeMsg(203, "仓库删除失败");
    public static CodeMsg GOODS_UPDATE = new CodeMsg(204, "商品更新失败");
    public static CodeMsg GOODS_BAR = new CodeMsg(204, "商品货号重复:");

    // 角色管理异常
    public static CodeMsg ROlE_EXIST = new CodeMsg(302, "角色已存在");
    public static CodeMsg RolE_DELETE = new CodeMsg(303, "角色删除失败,请检查该角色是否已被使用");
    public static CodeMsg ROLE_DELETE_ERROR = new CodeMsg(304, "不能删除已经被使用的角色");

    // 员工异常
    public static CodeMsg STAFF_EXIST = new CodeMsg(305, "员工账户已存在");
    public static CodeMsg STAFF_DELETE = new CodeMsg(306, "员工删除失败");
    public static CodeMsg STAFF_EDIT_ERROR = new CodeMsg(307, "员工编辑失败");
    public static CodeMsg STAFF_ERROR = new CodeMsg(3011, "未知错误");

    // 门店管理异常
    public static CodeMsg SHOP_EXIST = new CodeMsg(302, "门店已存在");
    public static CodeMsg SHOP_DELETE = new CodeMsg(303, "门店删除失败");
    public static CodeMsg SHOP_EDIT_ERROR = new CodeMsg(304, "门店编辑失败");

    // 条码异常
    public static CodeMsg BAECODE_EXIST = new CodeMsg(312, "现有厂商识别码下的产品代码已用完，请配置新的厂商识别码！");
    public static CodeMsg BAECODE_SAVE_ERROR = new CodeMsg(314, "条码保存错误");

    //公告异常
    public static CodeMsg ANNOUNCE_EXIST = new CodeMsg(305, "公告已存在");
    public static CodeMsg ANNOUNCE_DELETE = new CodeMsg(306, "公告删除失败");
    public static CodeMsg ANNOUNCE_EDIT_ERROR = new CodeMsg(307, "公告编辑失败");

    //供应商异常
    public static CodeMsg SUPPLIER_EXIST = new CodeMsg(308, "供应商已存在");
    public static CodeMsg SUPPLIER_DELETE = new CodeMsg(309, "供应商删除失败");
    public static CodeMsg SUPPLIER_EDIT_ERROR = new CodeMsg(310, "公告编辑失败");

    //出入库单管理
    public static CodeMsg INODER_NOT_EXIST = new CodeMsg(401, "入库单不存在");

    //客户异常
    public static CodeMsg CUSTOMER_EXIST = new CodeMsg(311, "客户名已存在");
    public static CodeMsg CUSTOMER_DELETE = new CodeMsg(312, "客户删除失败");
    public static CodeMsg CUSTOMER_EDIT_ERROR = new CodeMsg(313, "客户编辑失败");


    public CodeMsg(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
